import Vue from 'vue'
import VueRouter from 'vue-router'

import Layout from '@/layout'

Vue.use(VueRouter)

export const routes = [
  {
    path: '/login',
    name: 'Login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "Login" */ '@/views/login/index'),
    meta: { title: 'login' }
  },
  {
    path: '/',
    name: 'Index',
    component: Layout,
    redirect: '/index',
    meta: { title: '首页', icon: 'menu' },
    alwayShow: true,
    children: [{
      path: 'index',
      name: 'Index',
      components: () => import('@/views/index/index'),
      meta: { title: 'index', icon: 'setting', roles: ['admin', 'editor'] },
      hidden: false
    }]
  },
  {
    path: 'exmaple',
    name: 'Exmaple',
    component: Layout,
    redirect: 'exmaple/exmaple-user',
    children: [{
      path: 'exmaple-user',
      name: 'ExmapleUser',
      component: () => import('@/views/exmaple/exmaple-user'),
      meta: { title: 'user示例', icon: 'menu', roles: ['admin', 'editor'] },
      hidden: false
    }, {
      path: 'exmaple-role',
      name: 'ExmapleRole',
      component: () => import('@/views/exmaple/exmaple-role'),
      meta: { title: 'role示例', icon: 'menu', roles: ['admin', 'editor'] },
      hidden: false
    }]
  }
]

const router = new VueRouter({
  routes
})

export default router
